import http from './http'
// 注册 /api/user/register
export const registerApi = (username, password) => {
    return http({
        url: 'http://localhost:12345/api/user/register',
        method: 'POST',
        data: {
            username,
            password
        }
    })
}
// 登录 /api/user/login
export const loginApi = (username, password) => {
    return http({
        url: 'http://localhost:12345/api/user/login',
        method: 'POST',
        data: {
            username,
            password
        }
    })
}
// 楼层接口函数 https://api-hmugo-web.itheima.net/api/public/v1/home/floordata
export const floorApi = () => {
    return http({
        url: 'https://api-hmugo-web.itheima.net/api/public/v1/home/floordata',
        method: 'GET',
    })
}
// 商品搜索 h
export const searchApi = (query) => {
    return http({
        url: 'https://api-hmugo-web.itheima.net/api/public/v1/goods/qsearch',
        method: 'GET',
        params: {
            query
        }
    })
}
// 商品详情 
export const detailApi = (goods_id) => {
    return http({
        url: 'https://api-hmugo-web.itheima.net/api/public/v1/goods/detail',
        method: 'GET',
        params: {
            goods_id
        }
    })
}

// 商品分类
export const ClassApi = () => {
    return http({
        url: 'https://api-hmugo-web.itheima.net/api/public/v1/categories',
        method: 'GET',
    })
}

// 商品列表
export const GoodsApi = (query) => {
    return http({
        url: 'https://api-hmugo-web.itheima.net/api/public/v1/goods/search',
        method: 'GET',
        params: {
            query
        }
    })
}


// 生成订单
export const CreateOrderApi = (orders) => {
    return http({
        url: 'http://localhost:12345/api/order/create',
        method: 'POST',
        data: {
            ...orders
        }
    })
}


// 封装订单详情
// 导出一个名为OrderDetailApi的函数，用于获取订单详情
export const OrderDetailApi = (orderId) => {
    // 使用http方法发送GET请求，获取订单详情
    return http({
        url: 'http://localhost:12345/api/order/getOrder/' + orderId,
        method: 'GET',

    })
}


// 封装支付
export const payApi = (datas) => {
    return http({
        url: 'http://localhost:12345/api/order/pay',
        method: 'POST',
        data: {
            ...datas
        }

    })
}
export const getOrderListApi = (username) => {
    return http({
        url: 'http://localhost:12345/api/order/getOrderList/' + username,
        method: 'GET',

    })
}



